package com.chaofan.kings_poster.common;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by Chaofan at 2018-12-13 10:00
 * email:chaofan2685@qq.com
 * 该类负责全局异常拦截，只做简单处理
 **/

@ControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    @ResponseBody
    RestfulMessage handleException(Exception e){
        e.printStackTrace();
        RestfulMessage resultData = new RestfulMessage();
        resultData.setCode(8500);
        resultData.setMessage(e.getMessage());
        return resultData;
    }

}
